package org.codeCard.btn;

import com.tool.btn.MoBanBtn;
import org.cbg.bean.SearchGoodsBean;
import org.codeCard.frame.CodeCardJFrame;
import org.codeCard.panel.CodeCardBuyJPanel;
import org.codeCard.panel.CodeCardMainJPanel;
import org.come.socket.Agreement;
import org.come.socket.SendMessageUntil;
import org.come.until.GsonUtil;

import java.awt.*;
import java.awt.event.MouseEvent;

public class CodeCardBtn extends MoBanBtn {
    private int caozuo;
    private CodeCardMainJPanel bjczMainJpanel;

    public CodeCardBtn(String iconpath, int type, int caozuo, CodeCardMainJPanel bjczMainJpanel) {
        super(iconpath, type);
        this.caozuo = caozuo;
        this.bjczMainJpanel = bjczMainJpanel;
    }

    public CodeCardBtn(String iconpath, int type, Color[] colors, Font font, String text, int caozuo) {
        super(iconpath, type, colors);
        this.setText(text);
        this.setFont(font);
        this.setVerticalTextPosition(0);
        this.setHorizontalTextPosition(0);
        this.caozuo = caozuo;
    }

    public CodeCardBtn(String iconpath,String fileName , int type, int caozuo, CodeCardMainJPanel bjczMainJpanel) {
        super(iconpath, type);
        this.caozuo = caozuo;
        this.bjczMainJpanel = bjczMainJpanel;
    }

    public void chooseyes() {
    }

    public void chooseno() {
    }

    String sendmes;
    SearchGoodsBean searchGoodsBean;

    public void nochoose(MouseEvent e) {
        searchGoodsBean = new SearchGoodsBean();

        if(caozuo == 1){
            CodeCardJFrame.bjczMainJpanel.getBjczCardJpanel().getCardLayout()
        .show(CodeCardJFrame.bjczMainJpanel.getBjczCardJpanel(), "bjcz1Jpanel");

            CodeCardBuyJPanel.FLAG = true;
            searchGoodsBean.setSaletype(1);
            searchGoodsBean.setPageNum(1);
            sendmes = Agreement.getAgreement().saleCardSearchAgreement(
                    GsonUtil.getGsonUtil().getgson().toJson(searchGoodsBean));
            SendMessageUntil.toServer(sendmes);
        }else{

            CodeCardJFrame.bjczMainJpanel.getBjczCardJpanel().getCardLayout()
                    .show(CodeCardJFrame.bjczMainJpanel.getBjczCardJpanel(), "bjcz2Jpanel");

            CodeCardBuyJPanel.FLAG = false;

            searchGoodsBean.setSaletype(2);
            searchGoodsBean.setPageNum(1);
            sendmes = Agreement.getAgreement().saleCardMySearchAgreement(
                    GsonUtil.getGsonUtil().getgson().toJson(searchGoodsBean));
            SendMessageUntil.toServer(sendmes);
        }

//        if (MyIsif.getStyle().equals("水墨UI")) {
//            try {
//                if (caozuo == 1) {
//
//                    CodeCardJFrame.bjczMainJpanel.getBjczCardJpanel().getCardLayout()
//                            .show(CodeCardJFrame.bjczMainJpanel.getBjczCardJpanel(), "bjcz1Jpanel");
//
//                } else if (caozuo == 2) {
//
//
//                    CodeCardJFrame.bjczMainJpanel.getBjczCardJpanel().getCardLayout()
//                            .show(CodeCardJFrame.bjczMainJpanel.getBjczCardJpanel(), "bjcz2Jpanel");
//
//                }
//            } catch (Exception e1) {
//                e1.printStackTrace();
//            }
//        }else {
//            try {
//                if (this.caozuo == 1) {
//
//                    CodeCardJFrame.bjczMainJpanel.getBjczCardJpanel().getCardLayout().show(CodeCardJFrame.bjczMainJpanel.getBjczCardJpanel(), "bjcz1Jpanel");
//                } else if (this.caozuo == 2) {
//
//                    CodeCardJFrame.bjczMainJpanel.getBjczCardJpanel().getCardLayout().show(CodeCardJFrame.bjczMainJpanel.getBjczCardJpanel(), "bjcz2Jpanel");
//                }
//            } catch (Exception var11) {
//                var11.printStackTrace();
//            }
//        }

    }


}

